import 'dart:ui' as ui;
import 'package:flutter/material.dart';
import 'package:draw_window/basic.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';

class StandardGlass extends RegisterWidget {
  GlobalKey globalKey = new GlobalKey();
  ByteData data;
  ui.FrameInfo frameInfo;

  @override
  String get type {
    return "standard-glass";
  }

  @override
  RegisterWidget get clone {
    return StandardGlass();
  }

  @override
  void insert(Offset offset, Node parent) {
    parent.children.add([Node(type: type)]);
  }

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      child: Image.asset("resuorce/img/glass.jpg",
      width: node.width,
      height: node.height,
      alignment: Alignment.topLeft,
      fit: BoxFit.fill,),
    );
  }

  @override
  void update(Vary vary, double value) {

  }

//  @override
//  void paint(Canvas canvas, Offset offset, ImageConfiguration configuration) async {
//    final Rect rect = offset & configuration.size;
//    data ??= await rootBundle.load("resuorce/img/glass.jpg");
//    ui.Codec codec = await ui.instantiateImageCodec(data.buffer.asUint8List());
//    frameInfo ??= await codec.getNextFrame();
//    var image = frameInfo.image;
//    Rect src = Rect.fromLTRB(0.0, 0.0, image.width + 0.0, image.height + 0.0);
//    canvas.drawImageRect(image, src, rect, Paint()..style = PaintingStyle.fill);
//  }
}
